package com.jch.dm3.exercise.gui.l1;

import com.jch.dm3.exercise.GracefulThread;

public class Service {

    private static GracefulThread thread = null;

    public synchronized static void service(){
        System.out.println("service");
        if (thread != null && thread.isAlive()){
            System.out.print(" is balked.");
            return;
        }
        thread = new ServiceThread();
        thread.start();
    }

    public synchronized static void cancel(){
        if (thread != null){
            System.out.println("cancel.");
            thread.shutdownRequest();
        }
    }

}
